using System;
using NUnit.Framework;

using ValidationFramework.Specifications.Tests.Helpers;
using ValidationFramework.Specifications;

namespace ValidationFramework.Specifications.Tests
{
	[TestFixture]
	public class HasNoDuplicatesRuleAttributeTests
	{
		[TestFixture]
		public class Constructor1
		{
			[Test]
			public void Should_Return_Validtor_If_No_Properties_Are_Set()
			{
				// Arrange
				var mockDescriptor = new FakeReflectionInfo();
				var expectedSpec = new ContainsNoDuplicatesSpec();

				// Act
				var attribute = new ContainsNoDuplicatesAttribute();
				var validator = attribute.CreateSpecification(mockDescriptor);

				// Assert
				Assert.IsTrue(validator.IsEquivalentTo(expectedSpec));
			}

			[Test]
			public void Should_Resolve_Correct_Equality_Comparer()
			{
				// Arrange
				var mockDescriptor = new FakeReflectionInfo();
				var expectedSpec = new ContainsNoDuplicatesSpec(StringComparer.InvariantCulture);
				const string comparerTypeName = "System.StringComparer";
				const string comparerPropertyName = "InvariantCulture";

				// Act
				var attribute = new ContainsNoDuplicatesAttribute()
				{
					EqualityComparerTypeName = comparerTypeName,
					EqualityComparerPropertyName = comparerPropertyName
				};
				var validator = (ContainsNoDuplicatesSpec)attribute.CreateSpecification(mockDescriptor);

				// Assert
				Assert.AreEqual(validator.Comparer, StringComparer.InvariantCulture);
				Assert.IsTrue(validator.IsEquivalentTo(expectedSpec));
			}
		}
		[Test]
		public void Test()
		{
			Assert.IsTrue(true);
		}
	}
}